package com.qjc.demo.base;

import com.alibaba.fastjson.JSON;
import lombok.Data;

import java.io.Serializable;

/**
 * @Description:
 * @Author: qjc
 * @Date: 2020/8/12
 */
public class TransientTest {
    /**
     * 被transient关键字修饰的属性不会被序列化，transient不能修饰类和方法
     */
    public static void main(String[] args) {
        User user = new User();
        user.setUserName("a");
        user.setAge(10);
        user.setUserPassword("bb");

        String s = JSON.toJSONString(user);
        System.err.println(s);

    }
}

@Data
class User implements Serializable {
    private String userName;
    private transient String userPassword;
    private transient int age;
}